import { Module, Logger } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import * as Joi from 'joi';
import { app } from './configs';

const logger = new Logger('config.module');
const entFilePath = `${process.cwd()}/env/.env.${process.env.NODE_ENV}`;
logger.log(process.env.NODE_ENV);
logger.log('hello world', entFilePath);

@Module({
  imports: [
    ConfigModule.forRoot({
      envFilePath: [`${process.cwd()}/env/.env.${process.env.NODE_ENV}`],
      load: [
        app,
      ],
      cache: true,
      isGlobal: true,
      expandVariables: true,
      validationSchema: Joi.object({}),
      validationOptions: {
        abortEarly: true,
        // cache: !HelperService.isProd(),
        // debug: !HelperService.isProd(),
        // stack: !HelperService.isProd(),
      },
    }),
  ],
  providers: [ConfigService],
  exports: [ConfigService],
})
export class NestConfigModule {}
